package cn.zyq.ykb.controller.mgt.config;

import cn.zyq.ykb.beans.config.ConfigPropOrder;
import cn.zyq.ykb.service.config.ConfigPropOrderService;
import cn.zyq.ykb.system.annotation.Log;
import cn.zyq.ykb.system.common.BaseController;
import cn.zyq.ykb.system.common.PageParam;
import cn.zyq.ykb.system.ry.enums.BusinessType;
import cn.zyq.ykb.system.ry.util.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 配置-道具订单Controller
 *
 * @author SystemAuth
 * @date 2023-05-30
 */

@RestController(value = "MgtConfigPropOrderController")
@RequestMapping("/mgt/configPropOrder")
@Api(tags = "配置-道具订单接口")
public class ConfigPropOrderController extends BaseController {

    @Autowired
    private ConfigPropOrderService configPropOrderService;

    /**
     * 查询配置-道具订单列表
     */
    @ApiOperation(value = "列表", response = ConfigPropOrder.class)
    @PostMapping("/list")
    public Object list(@RequestBody PageParam pageParam) {
        return this.configPropOrderService.selectConfigPropOrderList(pageParam);
    }

     /**
      * 导出配置-道具订单列表
      */
     @ApiOperation(value = "导出")
     @Log(title = "配置-道具订单" , businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, ConfigPropOrder configPropOrder) {
         List<ConfigPropOrder> list = configPropOrderService.selectConfigPropOrderList(configPropOrder);
         ExcelUtil<ConfigPropOrder> util = new ExcelUtil<ConfigPropOrder>(ConfigPropOrder. class);
         util.exportExcel(response, list, "配置-道具订单数据");
     }

    /**
     * 获取配置-道具订单详细信息
     */
    @ApiOperation(value = "详情", response = ConfigPropOrder.class)
    @GetMapping(value = "/{configPropOrderID}")
    public Object getInfo(@PathVariable("configPropOrderID") Integer configPropOrderID) {
        return this.configPropOrderService.selectConfigPropOrderByConfigPropOrderID(configPropOrderID);
    }
    /**
     * 获取配置-道具订单详细信息
     */
    @ApiOperation(value = "详情", response = ConfigPropOrder.class)
    @GetMapping(value = "/detail/{serviceID}")
    public Object getInfo(@PathVariable(value = "serviceID") String serviceID) {
        return this.configPropOrderService.selectConfigPropOrderByServiceID(serviceID);
    }

    /**
     * 新增配置-道具订单
     */
    @ApiOperation(value = "新增")
    @Log(title = "配置-道具订单", businessType = BusinessType.INSERT)
    @PostMapping
    public Object add(@RequestBody ConfigPropOrder configPropOrder) {
        return this.configPropOrderService.insertConfigPropOrder(configPropOrder);
    }

    /**
     * 修改配置-道具订单
     */
    @ApiOperation(value = "编辑")
    @Log(title = "配置-道具订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public Object edit(@RequestBody ConfigPropOrder configPropOrder) {
        return this.configPropOrderService.updateConfigPropOrder(configPropOrder);
    }

    /**
     * 删除配置-道具订单
     */
    @ApiOperation(value = "删除")
    @Log(title = "配置-道具订单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{configPropOrderIDs}")
    public Object remove(@PathVariable Integer[] configPropOrderIDs) {
        return this.configPropOrderService.deleteConfigPropOrderByConfigPropOrderIDs(configPropOrderIDs);
    }
}
